<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------

namespace app\jobs\user;



use app\services\user\UserBelongStoreServices;
use app\services\user\UserVisitStoreServices;
use crmeb\basic\BaseJobs;
use crmeb\traits\QueueTrait;

class UserBelongStoreJob extends BaseJobs
{

    use QueueTrait;

	/**
	 * 记录用户归属门店
	 * @param $uid
	 * @param $storeId
	 * @param $type
	 * @param $staffId
	 * @return bool
	 */
    public function doJob($uid, $storeId, $type = 'order', $staffId = 0)
    {
        try {
			//记录用户归属门店
			/** @var UserBelongStoreServices $userBelongStoreServices */
			$userBelongStoreServices = app()->make(UserBelongStoreServices::class);
			$userBelongStoreServices->setUserBelongStore((int)$uid, (int)$storeId, (string)$type, (int)$staffId);
        } catch (\Throwable $e) {

        }
        return true;
    }

	/**
	 * 记录用户访问
	 * @param $uid
	 * @param $storeId
	 * @param $param
	 * @return bool
	 */
	public function setVisitStore($uid, $storeId, $param = [])
	{
		try {
			//记录用户访问门店
			/** @var UserVisitStoreServices $userVisitStoreServices */
			$userVisitStoreServices = app()->make(UserVisitStoreServices::class);
			$userVisitStoreServices->setVisitStore((int)$uid, (int)$storeId, (array)$param);
		} catch (\Throwable $e) {

		}
		return true;
	}

}
